package com.bruce.demo2.patterns.demo2.structural.demo12.flyweight.demo2;

/**
 * @PROJECT_NAME: design_patterns
 * @DESCRIPTION: 坦克抽象接口
 * @AUTHOR: CNBruceLee
 * @DATE: 2021/8/2 21:41
 */
public abstract class AbstractTank implements ITank {
    protected Flyweight speedFlyweight;
    protected Flyweight shootFlyweight;

    //设置坦克速度与炮弹速度
    public AbstractTank(Flyweight speedFlyweight, Flyweight shootFlyweight) {
        this.speedFlyweight = speedFlyweight;
        this.shootFlyweight = shootFlyweight;
    }

    /**
     * 获取坦克速度
     *
     * @return
     */
    public abstract int getSpeed();

    /**
     * 获取坦克射速
     *
     * @return
     */
    public abstract int getShoot();

    /**
     * 获取操作
     *
     * @return
     */
    public abstract String getOption();

    /**
     * 设置操作
     *
     * @return
     */
    public abstract void setOption(String option);

    /**
     * 对坦克的操作
     */
    public void operation(String option) {
        setOption(option);
        speedFlyweight.operation(getSpeed(), getOption());
        shootFlyweight.operation(getShoot(), getOption());
    }
}
